package com.ruoyi.controller;


import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.service.MaterielTwoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/materielTwo")
public class MaterielTwoController {
    @Autowired
    private MaterielTwoService materielTwoService;

    //查询生产物信息2
    @GetMapping("/select")
    public R select(int page, int limit, String lotCode, String itemCode1, String docDate) {
        if ((lotCode != null && !lotCode.isEmpty() )||
                (itemCode1 != null && !itemCode1.isEmpty())||
                (docDate != null && !docDate.isEmpty())){
            return R.ok(materielTwoService.selectMaterielTwo(page,limit,lotCode,itemCode1,docDate));
        }else{
            return R.ok(materielTwoService.allMaterielTwo(page,limit));
        }

    }

/*    @PostMapping( "/createMaterielTwo")
    public R createMaterielTwo(@RequestParam("itemDescription1")String itemDescription1,
                               @RequestParam("itemCode1")String itemCode1,
                               @RequestParam("itemSpecification1")String itemSpecification1,
                               @RequestParam("reqIncludeMuQty")Double reqIncludeMuQty,
                               @RequestParam("itemDescription")String itemDescription,
                               @RequestParam("lotCode")String lotCode
                          )  {

        // 将字符串转换为JSON
        JSONObject jsonContent = new JSONObject();
        jsonContent.put("itemDescription1",itemDescription1);
        jsonContent.put(" itemCode1", itemCode1);
        jsonContent.put("itemSpecification1", itemSpecification1);
        jsonContent.put("reqIncludeMuQty", reqIncludeMuQty);
        jsonContent.put("itemDescription",itemDescription);
        jsonContent.put("lotCode", lotCode);

        return R.ok(jsonContent);
    }*/

}

